package com.atguigu.java4;

import java.sql.Connection;

/**
 *      多态性的使用举例一：
 *
 *
 * @author : leimingchao
 * @date Date : 2021年08月25日 0:53
 */
public class AnimalTest {

    public static void main(String[] args) {
        AnimalTest test = new AnimalTest();
        test.func(new Dog());
        System.out.println();
        test.func(new Cat());
    }


    public void func(Animal animal) {
        animal.eat();
        animal.shout();
    }
}


class Animal {


    public void eat() {
        System.out.println("动物:进食");
    }

    public void shout() {
        System.out.println("动物：叫");
    }
}

class Dog extends Animal {


    public void eat() {
        System.out.println("狗吃骨头");
    }

    public void shout() {
        System.out.println("汪！汪！汪！");
    }
}


class Cat extends Animal {


    public void eat() {
        System.out.println("狗吃鱼");
    }

    public void shout() {
        System.out.println("喵！喵！喵！");
    }
}

/**
 * 举例二
 */
class Order {
    public void method(Object object) {

    }
}

/**
 * 举例三
 */
class Driver {

    public void doData(Connection connection) {
        //connection = new MySQLConnection();/ connection = new OracleConnection();
        //规范的步骤去操作数据
        // connection.method1();
        // connection.method2();
        // connection.method3();
    }
}
